import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  OneToMany,
} from 'typeorm';
import { Song } from '../song/song.entity';
import { Album } from '../album/album.entity';

// 歌手性别枚举
export enum Gender {
  MALE = 'male', // 男
  FEMALE = 'female', // 女
  GROUP = 'group', // 乐队组合
}

// 歌手类型枚举
export enum SingerType {
  POP = 'pop', // 流行
  ELECTRONIC = 'electronic', // 电子
  ROCK = 'rock', // 摇滚
  HIP_HOP = 'hiphop', // 嘻哈
  CLASSICAL = 'classical', // 古典
  FOLK = 'folk', // 民谣
  JAZZ = 'jazz', // 爵士
  OTHER = 'other', // 其他
}

@Entity()
export class Singer {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    unique: true,
    length: 50,
  })
  name: string;

  @Column({
    nullable: true,
    length: 5000,
  })
  description: string;

  @Column({
    nullable: true,
  })
  avatarUrl: string;

  @Column({
    nullable: true,
  })
  birthDate: Date;

  @Column({
    nullable: true,
    length: 100,
  })
  nationality: string;

  @Column({
    type: 'enum',
    enum: Gender,
    nullable: true,
  })
  gender: Gender;

  @Column({
    type: 'enum',
    enum: SingerType,
    default: SingerType.POP,
  })
  type: SingerType;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @OneToMany(() => Song, (song) => song.artist)
  songs: Song[];

  @OneToMany(() => Album, (album) => album.artist)
  albums: Album[];
}
